home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / siam / siam.bst < prev    next >
Text File  |  1993-01-11  |  18KB  |  1,036 lines

  1. % SIAM bibliography style (24-Jan-88 version)
  2. %    numeric labels, alphabetic order, Mathematical Reviews abbreviations,
  3. %    names in \sc, titles in italics, book titles mixed upper-lower and article
  4. %    titles lowercase, commas separate all fields except before "notes".
  5. %
  6. %   History
  7. %    1/30/86    (HWT)    Original version, by Howard Trickey.
  8. %    6/15/87    (HWT)    Fix format.editors---Martin Costabel.
  9. %    1/24/88    (OP&HWT) Updated for BibTeX version 0.99a, Oren Patashnik;
  10. %            THIS `siam' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
  11.  
  12. ENTRY
  13.   { address
  14.     author
  15.     booktitle
  16.     chapter
  17.     edition
  18.     editor
  19.     howpublished
  20.     institution
  21.     journal
  22.     key
  23.     month
  24.     note
  25.     number
  26.     organization
  27.     pages
  28.     publisher
  29.     school
  30.     series
  31.     title
  32.     type
  33.     volume
  34.     year
  35.   }
  36.   {}
  37.   { label }
  38.  
  39. INTEGERS { output.state before.all mid.sentence after.block }
  40.  
  41. FUNCTION {init.state.consts}
  42. { #0 'before.all :=
  43.   #1 'mid.sentence :=
  44.   #2 'after.block :=
  45. }
  46.  
  47. STRINGS { s t }
  48.  
  49. FUNCTION {output.nonnull}
  50. { 's :=
  51.   output.state mid.sentence =
  52.     { ", " * write$ }
  53.     { output.state after.block =
  54.     { add.period$ write$
  55.       newline$
  56.       "\newblock " write$
  57.     }
  58.     'write$
  59.       if$
  60.       mid.sentence 'output.state :=
  61.     }
  62.   if$
  63.   s
  64. }
  65.  
  66. FUNCTION {output}
  67. { duplicate$ empty$
  68.     'pop$
  69.     'output.nonnull
  70.   if$
  71. }
  72.  
  73. FUNCTION {output.check}
  74. { 't :=
  75.   duplicate$ empty$
  76.     { pop$ "empty " t * " in " * cite$ * warning$ }
  77.     'output.nonnull
  78.   if$
  79. }
  80.  
  81. FUNCTION {output.bibitem}
  82. { newline$
  83.   "\bibitem{" write$
  84.   cite$ write$
  85.   "}" write$
  86.   newline$
  87.   ""
  88.   before.all 'output.state :=
  89. }
  90.  
  91. FUNCTION {fin.entry}
  92. { add.period$
  93.   write$
  94.   newline$
  95. }
  96.  
  97. FUNCTION {new.block}
  98. { output.state before.all =
  99.     'skip$
  100.     { after.block 'output.state := }
  101.   if$
  102. }
  103.  
  104. FUNCTION {not}
  105. {   { #0 }
  106.     { #1 }
  107.   if$
  108. }
  109.  
  110. FUNCTION {and}
  111. {   'skip$
  112.     { pop$ #0 }
  113.   if$
  114. }
  115.  
  116. FUNCTION {or}
  117. {   { pop$ #1 }
  118.     'skip$
  119.   if$
  120. }
  121.  
  122. FUNCTION {new.block.checka}
  123. { empty$
  124.     'skip$
  125.     'new.block
  126.   if$
  127. }
  128.  
  129. FUNCTION {field.or.null}
  130. { duplicate$ empty$
  131.     { pop$ "" }
  132.     'skip$
  133.   if$
  134. }
  135.  
  136. FUNCTION {emphasize}
  137. { duplicate$ empty$
  138.     { pop$ "" }
  139.     { "{\em " swap$ * "}" * }
  140.   if$
  141. }
  142.  
  143. FUNCTION {scapify}
  144. { duplicate$ empty$
  145.     { pop$ "" }
  146.     { "{\sc " swap$ * "}" * }
  147.   if$
  148. }
  149.  
  150. INTEGERS { nameptr namesleft numnames }
  151.  
  152. FUNCTION {format.names}
  153. { 's :=
  154.   #1 'nameptr :=
  155.   s num.names$ 'numnames :=
  156.   numnames 'namesleft :=
  157.     { namesleft #0 > }
  158.     { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't :=
  159.       nameptr #1 >
  160.     { namesleft #1 >
  161.         { ", " * t * }
  162.         { numnames #2 >
  163.         { "," * }
  164.         'skip$
  165.           if$
  166.           t "others" =
  167.         { " et~al." * }
  168.         { " and " * t * }
  169.           if$
  170.         }
  171.       if$
  172.     }
  173.     't
  174.       if$
  175.       nameptr #1 + 'nameptr :=
  176.       namesleft #1 - 'namesleft :=
  177.     }
  178.   while$
  179. }
  180.  
  181. STRINGS { last.authors }
  182.  
  183. FUNCTION {init.last.authors}
  184. { "" 'last.authors :=
  185. }
  186.  
  187. FUNCTION {format.authors}
  188. { author empty$
  189.     { "" 'last.authors :=
  190.       ""
  191.     }
  192.     { author last.authors =
  193.         { "\leavevmode\vrule height 2pt depth -1.6pt width 23pt" }
  194.         { author format.names scapify }
  195.       if$
  196.       author 'last.authors :=
  197.     }
  198.   if$
  199. }
  200.  
  201. FUNCTION {format.organization}
  202. { organization empty$
  203.     { "" 'last.authors :=
  204.       ""
  205.     }
  206.     { organization last.authors =
  207.         { "\leavevmode\vrule height 2pt depth -1.6pt width 23pt" }
  208.         { organization scapify }
  209.       if$
  210.       organization 'last.authors :=
  211.     }
  212.   if$
  213. }
  214.  
  215. FUNCTION {format.editors}
  216. { editor empty$
  217.     { "" 'last.authors :=
  218.       ""
  219.     }
  220.     { editor last.authors =
  221.         { "\leavevmode\vrule height 2pt depth -1.6pt width 23pt" }
  222.     { editor format.names scapify }
  223.       if$
  224.       editor num.names$ #1 >
  225.         { ", eds." * }
  226.     { ", ed." * }
  227.       if$
  228.       editor 'last.authors :=
  229.     }
  230.   if$
  231. }
  232.  
  233. FUNCTION {format.ineditors}
  234. { editor empty$
  235.     { "" }
  236.     { editor format.names
  237.       editor num.names$ #1 >
  238.     { ", eds." * }
  239.     { ", ed." * }
  240.       if$
  241.     }
  242.   if$
  243. }
  244.  
  245. FUNCTION {format.title}
  246. { title empty$
  247.     { "" }
  248.     { title "t" change.case$ emphasize }
  249.   if$
  250. }
  251.  
  252. FUNCTION {n.dashify}
  253. { 't :=
  254.   ""
  255.     { t empty$ not }
  256.     { t #1 #1 substring$ "-" =
  257.     { t #1 #2 substring$ "--" = not
  258.         { "--" *
  259.           t #2 global.max$ substring$ 't :=
  260.         }
  261.         {   { t #1 #1 substring$ "-" = }
  262.         { "-" *
  263.           t #2 global.max$ substring$ 't :=
  264.         }
  265.           while$
  266.         }
  267.       if$
  268.     }
  269.     { t #1 #1 substring$ *
  270.       t #2 global.max$ substring$ 't :=
  271.     }
  272.       if$
  273.     }
  274.   while$
  275. }
  276.  
  277. FUNCTION {format.date}
  278. { year empty$
  279.     { month empty$
  280.     { "" }
  281.     { "there's a month but no year in " cite$ * warning$
  282.       month
  283.     }
  284.       if$
  285.     }
  286.     { month empty$
  287.     'year
  288.     { month " " * year * }
  289.       if$
  290.     }
  291.   if$
  292. }
  293.  
  294. FUNCTION {format.btitle}
  295. { title emphasize
  296. }
  297.  
  298. FUNCTION {tie.or.space.connect}
  299. { duplicate$ text.length$ #3 <
  300.     { "~" }
  301.     { " " }
  302.   if$
  303.   swap$ * *
  304. }
  305.  
  306. FUNCTION {either.or.check}
  307. { empty$
  308.     'pop$
  309.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  310.   if$
  311. }
  312.  
  313. FUNCTION {format.bvolume}
  314. { volume empty$
  315.     { "" }
  316.     { "vol.~" volume *
  317.       series empty$
  318.     'skip$
  319.     { " of " * series * }
  320.       if$
  321.       "volume and number" number either.or.check
  322.     }
  323.   if$
  324. }
  325.  
  326. FUNCTION {format.number.series}
  327. { volume empty$
  328.     { number empty$
  329.     { series field.or.null }
  330.     { "no.~" number *
  331.       series empty$
  332.         { "there's a number but no series in " cite$ * warning$ }
  333.         { " in " * series * }
  334.       if$
  335.     }
  336.       if$
  337.     }
  338.     { "" }
  339.   if$
  340. }
  341.  
  342. FUNCTION {format.edition}
  343. { edition empty$
  344.     { "" }
  345.     { edition "l" change.case$ "~ed." * }
  346.   if$
  347. }
  348.  
  349. INTEGERS { multiresult }
  350.  
  351. FUNCTION {multi.page.check}
  352. { 't :=
  353.   #0 'multiresult :=
  354.     { multiresult not
  355.       t empty$ not
  356.       and
  357.     }
  358.     { t #1 #1 substring$
  359.       duplicate$ "-" =
  360.       swap$ duplicate$ "," =
  361.       swap$ "+" =
  362.       or or
  363.     { #1 'multiresult := }
  364.     { t #2 global.max$ substring$ 't := }
  365.       if$
  366.     }
  367.   while$
  368.   multiresult
  369. }
  370.  
  371. FUNCTION {format.pages}
  372. { pages empty$
  373.     { "" }
  374.     { pages multi.page.check
  375.     { "pp.~" pages n.dashify * }
  376.     { "p.~" pages * }
  377.       if$
  378.     }
  379.   if$
  380. }
  381.  
  382. FUNCTION {format.vol.year}
  383. { volume field.or.null
  384.   year empty$
  385.     { "empty year in " cite$ * warning$ }
  386.     { " (" year * ")" * * }
  387.   if$
  388. }
  389.  
  390. FUNCTION {format.chapter.pages}
  391. { chapter empty$
  392.     'format.pages
  393.     { type empty$
  394.     { "ch.~" chapter * }
  395.     { type "l" change.case$ chapter tie.or.space.connect }
  396.       if$
  397.       pages empty$
  398.     'skip$
  399.     { ", " * format.pages * }
  400.       if$
  401.     }
  402.   if$
  403. }
  404.  
  405. FUNCTION {format.in.ed.booktitle}
  406. { booktitle empty$
  407.     { "" }
  408.     { editor empty$
  409.     { "in " booktitle * }
  410.     { "in " booktitle * ", " * format.ineditors * }
  411.       if$
  412.     }
  413.   if$
  414. }
  415.  
  416. FUNCTION {empty.misc.check}
  417. { author empty$ title empty$ howpublished empty$
  418.   month empty$ year empty$ note empty$
  419.   and and and and and
  420.   key empty$ not and
  421.     { "all relevant fields are empty in " cite$ * warning$ }
  422.     'skip$
  423.   if$
  424. }
  425.  
  426. FUNCTION {format.thesis.type}
  427. { type empty$
  428.     'skip$
  429.     { pop$
  430.       type "l" change.case$
  431.     }
  432.   if$
  433. }
  434.  
  435. FUNCTION {format.tr.number}
  436. { type empty$
  437.     { "Tech. Report" }
  438.     'type
  439.   if$
  440.   number empty$
  441.     { "l" change.case$ }
  442.     { number tie.or.space.connect }
  443.   if$
  444. }
  445.  
  446. FUNCTION {format.article.crossref}
  447. { key empty$
  448.     { journal empty$
  449.     { "need key or journal for " cite$ * " to crossref " * crossref *
  450.       warning$
  451.       ""
  452.     }
  453.     { "in " journal * }
  454.       if$
  455.     }
  456.     { "in " key * }
  457.   if$
  458.   " \cite{" * crossref * "}" *
  459. }
  460.  
  461. FUNCTION {format.crossref.editor}
  462. { editor #1 "{vv~}{ll}" format.name$
  463.   editor num.names$ duplicate$
  464.   #2 >
  465.     { pop$ " et~al." * }
  466.     { #2 <
  467.     'skip$
  468.     { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  469.         { " et~al." * }
  470.         { " and " * editor #2 "{vv~}{ll}" format.name$ * }
  471.       if$
  472.     }
  473.       if$
  474.     }
  475.   if$
  476. }
  477.  
  478. FUNCTION {format.book.crossref}
  479. { volume empty$
  480.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  481.       "in "
  482.     }
  483.     { "vol.~" volume *
  484.       " of " *
  485.     }
  486.   if$
  487.   editor empty$
  488.   editor field.or.null author field.or.null =
  489.   or
  490.     { key empty$
  491.     { series empty$
  492.         { "need editor, key, or series for " cite$ * " to crossref " *
  493.           crossref * warning$
  494.           "" *
  495.         }
  496.         { series * }
  497.       if$
  498.     }
  499.     { key * }
  500.       if$
  501.     }
  502.     { format.crossref.editor * }
  503.   if$
  504.   " \cite{" * crossref * "}" *
  505. }
  506.  
  507. FUNCTION {format.incoll.inproc.crossref}
  508. { editor empty$
  509.   editor field.or.null author field.or.null =
  510.   or
  511.     { key empty$
  512.     { booktitle empty$
  513.         { "need editor, key, or booktitle for " cite$ * " to crossref " *
  514.           crossref * warning$
  515.           ""
  516.         }
  517.         { "in " booktitle * }
  518.       if$
  519.     }
  520.     { "in " key * }
  521.       if$
  522.     }
  523.     { "in " format.crossref.editor * }
  524.   if$
  525.   " \cite{" * crossref * "}" *
  526. }
  527.  
  528. FUNCTION {article}
  529. { output.bibitem
  530.   format.authors "author" output.check
  531.   format.title "title" output.check
  532.   crossref missing$
  533.     { journal "journal" output.check
  534.       format.vol.year output
  535.     }
  536.     { format.article.crossref output.nonnull }
  537.   if$
  538.   format.pages output
  539.   new.block
  540.   note output
  541.   fin.entry
  542. }
  543.  
  544. FUNCTION {book}
  545. { output.bibitem
  546.   author empty$
  547.     { format.editors "author and editor" output.check }
  548.     { format.authors output.nonnull
  549.       crossref missing$
  550.     { "author and editor" editor either.or.check }
  551.     'skip$
  552.       if$
  553.     }
  554.   if$
  555.   format.btitle "title" output.check
  556.   crossref missing$
  557.     { format.bvolume output
  558.       format.number.series output
  559.       publisher "publisher" output.check
  560.       address output
  561.     }
  562.     { format.book.crossref output.nonnull }
  563.   if$
  564.   format.edition output
  565.   format.date "year" output.check
  566.   new.block
  567.   note output
  568.   fin.entry
  569. }
  570.  
  571. FUNCTION {booklet}
  572. { output.bibitem
  573.   format.authors output
  574.   format.title "title" output.check
  575.   howpublished new.block.checka
  576.   howpublished output
  577.   address output
  578.   format.date output
  579.   new.block
  580.   note output
  581.   fin.entry
  582. }
  583.  
  584. FUNCTION {inbook}
  585. { output.bibitem
  586.   author empty$
  587.     { format.editors "author and editor" output.check }
  588.     { format.authors output.nonnull
  589.       crossref missing$
  590.     { "author and editor" editor either.or.check }
  591.     'skip$
  592.       if$
  593.     }
  594.   if$
  595.   format.btitle "title" output.check
  596.   crossref missing$
  597.     { format.bvolume output
  598.       format.number.series output
  599.       publisher "publisher" output.check
  600.       address output
  601.     }
  602.     { format.book.crossref output.nonnull }
  603.   if$
  604.   format.edition output
  605.   format.date "year" output.check
  606.   format.chapter.pages "chapter and pages" output.check
  607.   new.block
  608.   note output
  609.   fin.entry
  610. }
  611.  
  612. FUNCTION {incollection}
  613. { output.bibitem
  614.   format.authors "author" output.check
  615.   format.title "title" output.check
  616.   crossref missing$
  617.     { format.in.ed.booktitle "booktitle" output.check
  618.       format.bvolume output
  619.       format.number.series output
  620.       publisher "publisher" output.check
  621.       address output
  622.       format.edition output
  623.       format.date "year" output.check
  624.     }
  625.     { format.incoll.inproc.crossref output.nonnull }
  626.   if$
  627.   format.chapter.pages output
  628.   new.block
  629.   note output
  630.   fin.entry
  631. }
  632.  
  633. FUNCTION {inproceedings}
  634. { output.bibitem
  635.   format.authors "author" output.check
  636.   format.title "title" output.check
  637.   crossref missing$
  638.     { format.in.ed.booktitle "booktitle" output.check
  639.       format.bvolume output
  640.       format.number.series output
  641.       address empty$
  642.     { organization output
  643.       publisher output
  644.       format.date "year" output.check
  645.     }
  646.     { address output.nonnull
  647.       format.date "year" output.check
  648.       organization output
  649.       publisher output
  650.     }
  651.       if$
  652.     }
  653.     { format.incoll.inproc.crossref output.nonnull }
  654.   if$
  655.   format.pages output
  656.   new.block
  657.   note output
  658.   fin.entry
  659. }
  660.  
  661. FUNCTION {conference} { inproceedings }
  662.  
  663. FUNCTION {manual}
  664. { output.bibitem
  665.   author empty$
  666.     { format.organization output }
  667.     { format.authors output.nonnull }
  668.   if$
  669.   format.btitle "title" output.check
  670.   author empty$
  671.     'skip$
  672.     { organization output }
  673.   if$
  674.   address output
  675.   format.edition output
  676.   format.date output
  677.   new.block
  678.   note output
  679.   fin.entry
  680. }
  681.  
  682. FUNCTION {mastersthesis}
  683. { output.bibitem
  684.   format.authors "author" output.check
  685.   format.title "title" output.check
  686.   "master's thesis" format.thesis.type output.nonnull
  687.   school "school" output.check
  688.   address output
  689.   format.date "year" output.check
  690.   new.block
  691.   note output
  692.   fin.entry
  693. }
  694.  
  695. FUNCTION {misc}
  696. { output.bibitem
  697.   format.authors output
  698.   format.title output
  699.   howpublished new.block.checka
  700.   howpublished output
  701.   format.date output
  702.   new.block
  703.   note output
  704.   fin.entry
  705.   empty.misc.check
  706. }
  707.  
  708. FUNCTION {phdthesis}
  709. { output.bibitem
  710.   format.authors "author" output.check
  711.   format.btitle "title" output.check
  712.   "PhD thesis" format.thesis.type output.nonnull
  713.   school "school" output.check
  714.   address output
  715.   format.date "year" output.check
  716.   new.block
  717.   note output
  718.   fin.entry
  719. }
  720.  
  721. FUNCTION {proceedings}
  722. { output.bibitem
  723.   editor empty$
  724.     { format.organization output }
  725.     { format.editors output.nonnull }
  726.   if$
  727.   format.btitle "title" output.check
  728.   format.bvolume output
  729.   format.number.series output
  730.   address empty$
  731.     { editor empty$
  732.     'skip$
  733.     { organization output }
  734.       if$
  735.       publisher output
  736.       format.date "year" output.check
  737.     }
  738.     { address output.nonnull
  739.       format.date "year" output.check
  740.       editor empty$
  741.     'skip$
  742.     { organization output }
  743.       if$
  744.       publisher output
  745.     }
  746.   if$
  747.   new.block
  748.   note output
  749.   fin.entry
  750. }
  751.  
  752. FUNCTION {techreport}
  753. { output.bibitem
  754.   format.authors "author" output.check
  755.   format.title "title" output.check
  756.   format.tr.number output.nonnull
  757.   institution "institution" output.check
  758.   address output
  759.   format.date "year" output.check
  760.   new.block
  761.   note output
  762.   fin.entry
  763. }
  764.  
  765. FUNCTION {unpublished}
  766. { output.bibitem
  767.   format.authors "author" output.check
  768.   format.title "title" output.check
  769.   new.block
  770.   note "note" output.check
  771.   format.date output
  772.   fin.entry
  773. }
  774.  
  775. FUNCTION {default.type} { misc }
  776.  
  777. MACRO {jan} {"Jan."}
  778.  
  779. MACRO {feb} {"Feb."}
  780.  
  781. MACRO {mar} {"Mar."}
  782.  
  783. MACRO {apr} {"Apr."}
  784.  
  785. MACRO {may} {"May"}
  786.  
  787. MACRO {jun} {"June"}
  788.  
  789. MACRO {jul} {"July"}
  790.  
  791. MACRO {aug} {"Aug."}
  792.  
  793. MACRO {sep} {"Sept."}
  794.  
  795. MACRO {oct} {"Oct."}
  796.  
  797. MACRO {nov} {"Nov."}
  798.  
  799. MACRO {dec} {"Dec."}
  800.  
  801. MACRO {acmcs} {"ACM Comput. Surveys"}
  802.  
  803. MACRO {acta} {"Acta Inf."}
  804.  
  805. MACRO {cacm} {"Comm. ACM"}
  806.  
  807. MACRO {ibmjrd} {"IBM J. Res. Dev."}
  808.  
  809. MACRO {ibmsj} {"IBM Syst.~J."}
  810.  
  811. MACRO {ieeese} {"IEEE Trans. Softw. Eng."}
  812.  
  813. MACRO {ieeetc} {"IEEE Trans. Comput."}
  814.  
  815. MACRO {ieeetcad}
  816.  {"IEEE Trans. Comput.-Aided Design Integrated Circuits"}
  817.  
  818. MACRO {ipl} {"Inf. Process. Lett."}
  819.  
  820. MACRO {jacm} {"J.~Assoc. Comput. Mach."}
  821.  
  822. MACRO {jcss} {"J.~Comput. System Sci."}
  823.  
  824. MACRO {scp} {"Sci. Comput. Programming"}
  825.  
  826. MACRO {sicomp} {"SIAM J. Comput."}
  827.  
  828. MACRO {tocs} {"ACM Trans. Comput. Syst."}
  829.  
  830. MACRO {tods} {"ACM Trans. Database Syst."}
  831.  
  832. MACRO {tog} {"ACM Trans. Gr."}
  833.  
  834. MACRO {toms} {"ACM Trans. Math. Softw."}
  835.  
  836. MACRO {toois} {"ACM Trans. Office Inf. Syst."}
  837.  
  838. MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."}
  839.  
  840. MACRO {tcs} {"Theoretical Comput. Sci."}
  841.  
  842. READ
  843.  
  844. FUNCTION {sortify}
  845. { purify$
  846.   "l" change.case$
  847. }
  848.  
  849. INTEGERS { len }
  850.  
  851. FUNCTION {chop.word}
  852. { 's :=
  853.   'len :=
  854.   s #1 len substring$ =
  855.     { s len #1 + global.max$ substring$ }
  856.     's
  857.   if$
  858. }
  859.  
  860. FUNCTION {sort.format.names}
  861. { 's :=
  862.   #1 'nameptr :=
  863.   ""
  864.   s num.names$ 'numnames :=
  865.   numnames 'namesleft :=
  866.     { namesleft #0 > }
  867.     { nameptr #1 >
  868.     { "   " * }
  869.     'skip$
  870.       if$
  871.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't :=
  872.       nameptr numnames = t "others" = and
  873.     { "et al" * }
  874.     { t sortify * }
  875.       if$
  876.       nameptr #1 + 'nameptr :=
  877.       namesleft #1 - 'namesleft :=
  878.     }
  879.   while$
  880. }
  881.  
  882. FUNCTION {sort.format.title}
  883. { 't :=
  884.   "A " #2
  885.     "An " #3
  886.       "The " #4 t chop.word
  887.     chop.word
  888.   chop.word
  889.   sortify
  890.   #1 global.max$ substring$
  891. }
  892.  
  893. FUNCTION {author.sort}
  894. { author empty$
  895.     { key empty$
  896.     { "to sort, need author or key in " cite$ * warning$
  897.       ""
  898.     }
  899.     { key sortify }
  900.       if$
  901.     }
  902.     { author sort.format.names }
  903.   if$
  904. }
  905.  
  906. FUNCTION {author.editor.sort}
  907. { author empty$
  908.     { editor empty$
  909.     { key empty$
  910.         { "to sort, need author, editor, or key in " cite$ * warning$
  911.           ""
  912.         }
  913.         { key sortify }
  914.       if$
  915.     }
  916.     { editor sort.format.names }
  917.       if$
  918.     }
  919.     { author sort.format.names }
  920.   if$
  921. }
  922.  
  923. FUNCTION {author.organization.sort}
  924. { author empty$
  925.     { organization empty$
  926.     { key empty$
  927.         { "to sort, need author, organization, or key in " cite$ * warning$
  928.           ""
  929.         }
  930.         { key sortify }
  931.       if$
  932.     }
  933.     { "The " #4 organization chop.word sortify }
  934.       if$
  935.     }
  936.     { author sort.format.names }
  937.   if$
  938. }
  939.  
  940. FUNCTION {editor.organization.sort}
  941. { editor empty$
  942.     { organization empty$
  943.     { key empty$
  944.         { "to sort, need editor, organization, or key in " cite$ * warning$
  945.           ""
  946.         }
  947.         { key sortify }
  948.       if$
  949.     }
  950.     { "The " #4 organization chop.word sortify }
  951.       if$
  952.     }
  953.     { editor sort.format.names }
  954.   if$
  955. }
  956.  
  957. FUNCTION {presort}
  958. { type$ "book" =
  959.   type$ "inbook" =
  960.   or
  961.     'author.editor.sort
  962.     { type$ "proceedings" =
  963.     'editor.organization.sort
  964.     { type$ "manual" =
  965.         'author.organization.sort
  966.         'author.sort
  967.       if$
  968.     }
  969.       if$
  970.     }
  971.   if$
  972.   "    "
  973.   *
  974.   year field.or.null sortify
  975.   *
  976.   "    "
  977.   *
  978.   title field.or.null
  979.   sort.format.title
  980.   *
  981.   #1 entry.max$ substring$
  982.   'sort.key$ :=
  983. }
  984.  
  985. ITERATE {presort}
  986.  
  987. SORT
  988.  
  989. STRINGS { longest.label }
  990.  
  991. INTEGERS { number.label longest.label.width }
  992.  
  993. FUNCTION {initialize.longest.label}
  994. { "" 'longest.label :=
  995.   #1 'number.label :=
  996.   #0 'longest.label.width :=
  997. }
  998.  
  999. FUNCTION {longest.label.pass}
  1000. { number.label int.to.str$ 'label :=
  1001.   number.label #1 + 'number.label :=
  1002.   label width$ longest.label.width >
  1003.     { label 'longest.label :=
  1004.       label width$ 'longest.label.width :=
  1005.     }
  1006.     'skip$
  1007.   if$
  1008. }
  1009.  
  1010. EXECUTE {initialize.longest.label}
  1011.  
  1012. ITERATE {longest.label.pass}
  1013.  
  1014. FUNCTION {begin.bib}
  1015. { preamble$ empty$
  1016.     'skip$
  1017.     { preamble$ write$ newline$ }
  1018.   if$
  1019.   "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
  1020. }
  1021.  
  1022. EXECUTE {begin.bib}
  1023.  
  1024. EXECUTE {init.state.consts}
  1025.  
  1026. EXECUTE {init.last.authors}
  1027.  
  1028. ITERATE {call.type$}
  1029.  
  1030. FUNCTION {end.bib}
  1031. { newline$
  1032.   "\end{thebibliography}" write$ newline$
  1033. }
  1034.  
  1035. EXECUTE {end.bib}
  1036.